﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MN.Framework.Common;
using MN.Framework.MetaData;
using MN.Framework.Extensions;
using System.Xml.Serialization;

namespace TZ.Common
{
    [EntityHeader("افراد")]
    [SearchFields("Name")]
    public partial class Person : BaseEntity
    {

        public Dictionary<string, string> GenderList { get; set; }

        public override void GetColumns(List<ColumnInfo> columns)
        {
            columns.Add(new NumericColumnInfo("ID", "شناسه", true));
            columns.Add(new LookupColumnInfo("Gender", "جنسیت", typeof(int), GenderList));
            columns.Add(new TextColumnInfo("Name", "نام"));
            columns.Add(new TextColumnInfo("PhoneNumber", "شماره تماس", 10));
            columns.Add(new TextColumnInfo("Mobile", "شماره همراه", 10));
            columns.Add(new TextColumnInfo("Address", "آدرس", ColumnSize.XXLarg));
            columns.Add(new ImageColumnInfo("Img", "عکس فرد", ColumnSize.XLarg));
        }
        public override void RegisterValidationRules()
        {
            base.RegisterValidationRules();

            base.AddRule("Name", new RequiredValidationRule());
            base.AddRule("Address", new RequiredValidationRule());
            base.AddRule("PhoneNumber", new TextValidationRule(TextOperator.PhoneNumber));
            base.AddRule("Mobile", new TextValidationRule(TextOperator.Mobile));
        }
        public override void SetDefaultValues()
        {
            base.SetDefaultValues();
            GenderList = new Dictionary<string, string>();
            GenderList.Add("1", "مرد");
            GenderList.Add("2", "زن");
            this.Img = ResourceImages.user.ToByteArray();
        }
    }

}
